<?php session_start(); ?>
<?php
include('../ketnoi.php');
include_once("fckeditor/fckeditor.php") ;
if (!$_SESSION['user']) header("location: index.php"); // nếu biến session['banguyen'] chưa có thì trở về trang đăng nhập, copy dòng này vào trang nào muốn bảo vệ bằng mật khẩu
?>
<style type="text/css">
<!--
.error, .notice, .success {padding:.8em;margin:auto; margin-bottom:.5em;border:2px solid #AAF;width:570px;text-align: center}
.error {background: #ECECFF;color: red;border-color:#AAF;}
-->
</style>
<style type="text/css">

.xem {
FONT-SIZE: 13px; 
	COLOR: #0000FF;
	font-weight: bold;
	background-color:#FFFFFF;
}
.xem a {
	color: #0000FF;
	text-decoration: none;
}
.xem a:link, a:visited {
	color: #0000FF;
	text-decoration: none;
}
</style>
<script type="text/javascript" src="scripts/joomla.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/_samples/sample.js" type="text/javascript"></script>
<div class="m">
 <?php 
    $shop=$dulieu;
	if($_GET['action']=='view' && $_GET['option']=='com_lt')
	{
		$sql1 = "SELECT * FROM `".$shop."`.`lophoclienthong` order by MaLopLT asc";
		$ketqua = mysql_query($sql1) or die ('khong tim thay du lieu');
		$tong=mysql_num_rows($ketqua);
		if($_POST['limit']==""){$sotrang = ceil($tong/20);}else{
		$sotrang = ceil($tong/$_POST['limit']);}
	    $dem = -1;
		
	if(isset($_POST['trang'])){
	 $trang = $_POST['trang'];
	}else{	
     if(isset($_POST['end'])){
	  $trang =$sotrang;
	 }else{
	  if(isset($_POST['start'])){
	   $trang =1;
	  }else{
	   $trang=1;
	  }
	 }	
	}
?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="index.php"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>

	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" href="?option=com_lt&action=insert"><img src="images/toolbar/icon-32-new.png" alt="New"><br><span>New</span></a>
	</div>
	</div>
</div>

<div class="header" style="background: url(images/dashboard/icon-48-article.png) no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Liên thông đại học</h2></div><br /><br />
<form name="adminForm" action="" method="post">
					
					<input name="option" value="com_lt" type="hidden">
					<input name="boxchecked" type="hidden">
					<input name="task" value="" type="hidden">
					<input name="func" value="" type="hidden">

<table class="adminlist" width="50%">
<tbody><tr><th width="3%" class="title">#</th>
<th width="4%" class="title"><input name="toggle" value="" onclick="checkAll(<?php if($_POST['limit']==""){echo '20';}else{echo $_POST['limit']; } ?>)" type="checkbox"></th>
<th class="title" width="45%"> 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ngành đào tạo</th>
<th width="6%" class="title"> &nbsp;Sửa </th>
<th class="title" width="6%"> &nbsp;Xóa</th>
</tr>
 <?php 
	$stt=0;
	$t=0;
   while($dongDL = mysql_fetch_array($ketqua))
	  { 
	  $dem++;
	    if($_POST['limit']==""){$s=20;}
		else{$s=$_POST['limit'];}
		if($dem >= ($trang-1)*$s && $dem <= ($trang*$s)-1)
		{
  ?>
  
<tr class="row<?php echo $t ?>">
<td align="center"><?php echo $dem+1 ?></td>
<td align="center"><input id="cb<?php echo $stt ?>" name="product_id[<?php echo $dongDL['MaLopLT']?>]" value="<?php echo $dongDL['MaLopLT']?>" onclick="isChecked(this.checked);" type="checkbox"></td>
<td class="xem"> <a style=" font-variant:small-caps" href="?option=com_lt&action=xem&amp;id=<?php echo $dongDL['MaLopLT'] ?>"><?php echo $dongDL['TenLopLT']?></a>
</td>
<td align="center"><a href="?option=com_lt&action=update&amp;id=<?php echo $dongDL['MaLopLT'] ?>"><img src="images/edit_f2.png" width="20" height="20" name="Edit<?php echo $stt+1 ?>" alt="Edit" border="0"></a></td>
<td align="center"><a class="toolbar" href="?option=com_lt&action=delete&amp;id=<?php echo $dongDL['MaLopLT'] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa?');"><img src="images/delete_f2.png" width="20" height="20"alt="Delete" name="delete<?php echo $stt+1 ?>" align="middle" border="0"></a></td>
</tr>
	 <?php
	 $stt=$stt+1;
	 if($t==0)$t=1;
	 else $t=0;
	 }
	  }//ket thuc ham while in du lieu
	  ?>
</tbody></table>

<table class="adminlist"><tbody>
<?php if($sotrang > 1 && $keyword==""){?>
<tr>
  <td colspan="3" align="center"> 
  <input name="start" class="button2" type="submit" value="Start"/>
  <?php
for($i=1; $i<=$sotrang; $i++)
{ ?>
	<input name="trang" class="button" type="submit" value="<?php echo $i;?>"/>
<?php 
}
?>
<input name="end" class="button2" type="submit" value="End"/></td></tr>
<?php } ?>
<?php 
if($keyword=="" && $chude=='' && $trangthai==''){
?>
<tr><td width="48%" align="right" nowrap="nowrap">Display #</td><td>
<select class="inputbox" name="limit" size="1" onchange="this.form.submit();">
<option value="5"  <?php if($_POST['limit']==5) echo "selected='selected'" ?>>5</option>
<option value="10" <?php if($_POST['limit']==10) echo "selected='selected'" ?>>10</option>
<option value="15" <?php if($_POST['limit']==15) echo "selected='selected'" ?>>15</option>
<option value="20" <?php if($_POST['limit']=='') echo "selected='selected'" ?>>20</option>
<option value="25" <?php if($_POST['limit']==25) echo "selected='selected'" ?>>25</option>
<option value="30" <?php if($_POST['limit']==30) echo "selected='selected'" ?>>30</option>
<option value="50" <?php if($_POST['limit']==35) echo "selected='selected'" ?>>50</option>
</select>
</td><td width="48%" align="left" nowrap="nowrap">Results 1 - 
<?php if($_POST['limit']==''){if($tong < 20 ){echo $tong;}else echo '20';} else{if($_POST['limit'] > $tong ){echo $tong;}else echo $_POST['limit'];}?> of <?php echo $tong ?></td></tr>
<?php }else{
?>
<tr><td width="48%" align="right" nowrap="nowrap">Display #</td><td>
<select class="inputbox" name="limit" size="1" disabled="disabled">
<option><?php echo $tong1; ?></option>
</select>
</td><td width="48%" align="left" nowrap="nowrap"><?php if($tong1 >0){?>Results 1 - 
<?php echo $tong1;?> of <?php echo $tong1; }?></td></tr>
<?php
}
?>
</tbody></table>
</form>
<?php
}//ket thuc view

if($_GET['action']=='delete' && $_GET['option']=='com_lt')
	{
		  $sql = "Delete from `".$shop."`.`lophoclienthong` where MaLopLT = '".$_GET['id']."'";
		  $delete = mysql_query($sql);
          echo"<script language=javascript>window.location='index.php?option=com_lt&action=view';</script>";
	  }// ket thuc kiem tra action Delete
	  
 
if($_GET['action']=='insert' && $_GET['option']=='com_lt')
{
	
if ( isset( $_POST['title'] ) ){

if ( isset( $_POST ) )
   $postArray = &$_POST ;			// 4.1.0 or later, use $_POST
else
   $postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS	

$stt=0;
while (list($sForm,$value)=each($postArray))
{
$stt++;
if ( get_magic_quotes_gpc() )
	$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
else
	$postedValue = htmlspecialchars( $value ) ;
$b[$stt]=$postedValue;
}	
 ?>
 	<form  name="form1" method="post">
    <input name="txt1" type="hidden"  id="txt1" value="<?=$b[1]?>" />
    <input name="txt2"  type="hidden" id="txt2" value="<?=$b[2]?>" />
	</form>
	
	<script language="JavaScript" type="text/javascript">
 		document.form1.submit();
    </script> 
 <?php

}
 if ( isset( $_POST['txt1'] ) ){	
 	$error="";
	if($_POST['txt1']=="" ){
	  $error="Vui lòng nhập đầy đủ các field.";
    }else{
       $sql = "INSERT INTO `".$shop."`.`lophoclienthong` (`TenLopLT`,`NoiDungHocLT`) VALUES ('".$_POST['txt1']."', '".$_POST['txt2']."');";
       $insert = mysql_query($sql);
       echo"<script language=javascript>window.location='index.php?option=com_lt&action=view';</script>";
	}

}
	?>
	<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="?option=com_lt&action=view"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>
	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" onclick="adminForm2.submit();"><img src="images/toolbar/icon-32-save.png"  alt="New"><br><span>Save</span></a>
	</div>
	</div>
</div>

<div class="header" style="background: url(images/dashboard/icon-48-article-add.png) no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Liên thông đại học: <small><small>[ Thêm mới ]</small></small></h2>
</div><br /><br />
<?php
	if($error!=""){
	?>
	 <div class="error" align="center"><img src='../images/cancel_f2.png' width='10px' height='10px'/> <?php echo $error ?></div>
  <?php
  }
?>
		<form name="adminForm2" action="" method="post" enctype="multipart/form-data">

<table style="margin-left:10px; font-size:14px; padding-left:10px" width="706" border="0" cellpadding="0" cellspacing="0" class="adminform">
		<tr><td colspan="4">&nbsp;</td></tr>
		<tr >
			<td style="padding-left:10px; font-weight:bold" width="68"> Ngành học:</td>
			<td  width="210">
		  <input style="margin-left:10px; width:300px" name="title" id="title" size="30" type="text">			</td>
			<td style="padding-left:20px; font-weight:bold" width="88">&nbsp;</td>
			<td width="118">&nbsp;</td>
		</tr>
		<tr><td colspan="4">&nbsp;</td></tr></table>
	<p></p>	
<table style="margin-left:10px; font-size:14px; padding-left:10px" border="0" cellpadding="0" cellspacing="0" class="adminform">
<tr><td style="padding-left:10px; font-weight:bold" height="35" valign="middle"> Nội dung ngành học </td></tr>
<tr><td>
<?php
		$oFCKeditor = new FCKeditor('FCKeditor1') ;
		$oFCKeditor->BasePath = '/fckeditor/' ;
		$oFCKeditor->Value = '';
		$oFCKeditor->Create() ;
	?>
   </td></tr></table>
</form>
<?php
}// ket thuc kiem tra action insert



if($_GET['action']=='update' && $_GET['option']=='com_lt')
	{
		$sql ="SELECT * from `".$shop."`.`lophoclienthong` where MaLopLT = '".$_GET['id']."'";
		$ketqua = mysql_query($sql);
		$dulieu = mysql_fetch_array($ketqua);
		
		
if ( isset( $_POST['title'] ) ){

if ( isset( $_POST ) )
   $postArray = &$_POST ;			// 4.1.0 or later, use $_POST
else
   $postArray = &$HTTP_POST_VARS ;	// prior to 4.1.0, use HTTP_POST_VARS	

$stt=0;
while (list($sForm,$value)=each($postArray))
{
$stt++;
if ( get_magic_quotes_gpc() )
	$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
else
	$postedValue = htmlspecialchars( $value ) ;
$b[$stt]=$postedValue;
}
	
 ?>
 	<form  name="form2" method="post">
    <input name="txt1" type="hidden"  id="txt1" value="<?=$b[1]?>" />
    <input name="txt2"  type="hidden" id="txt2" value="<?=$b[2]?>" />
	</form>
    
	
	<script language="JavaScript" type="text/javascript">
 		document.form2.submit();
    </script> 
 <?php

}
if ( isset( $_POST['txt1'] ) ){	
 	$error="";
	if($_POST['txt1']=="" ){
	  $error="Vui lòng nhập đầy đủ các field.";
    }else{
       $sql = "UPDATE `".$shop."`.`lophoclienthong` SET  `TenLopLT` = '".$_POST['txt1']."', `NoiDungHocLT` = '".$_POST['txt2']."'  WHERE `lophoclienthong`.`MaLopLT` = '".$_GET['id']."'";
      $update = mysql_query($sql) or die($sql);
      echo"<script language=javascript>window.location='index.php?option=com_lt&action=view';</script>";   	 	 	 	
	}

}
	?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="?option=com_lt&action=view"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>
	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" onclick="adminForm3.submit();"><img src="images/toolbar/icon-32-save.png"  alt="New"><br><span>Save</span></a>
	</div>
	</div>
</div>

<div class="header" style="background: url(images/dashboard/icon-48-article-add.png) no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Liên thông đại học: <small><small>[ Sửa]</small></small></h2>
</div><br /><br />
		<form name="adminForm3" action="" method="post" enctype="multipart/form-data">

<table style="margin-left:10px; font-size:14px; padding-left:10px" width="706" border="0" cellpadding="0" cellspacing="0" class="adminform">
		<tr><td colspan="4">&nbsp;</td></tr>
		<tr >
			<td style="padding-left:10px; font-weight:bold" width="68"> Ngành học:</td>
			<td  width="210">
		  <input style="margin-left:10px; width:300px" name="title" id="title" size="30" type="text" value="<?php echo $dulieu['TenLopLT']?>">			</td>
			<td style="padding-left:20px; font-weight:bold" width="88">&nbsp;</td>
			<td width="118">&nbsp;</td>
		</tr>
		<tr><td colspan="4">&nbsp;</td></tr></table>
	<p></p>	
<table style="margin-left:10px; font-size:14px; padding-left:10px" border="0" cellpadding="0" cellspacing="0" class="adminform">
<tr><td style="padding-left:10px; font-weight:bold" height="35" valign="middle"> Nội dung ngành học </td></tr>
<tr><td>
<?php
		$oFCKeditor = new FCKeditor('FCKeditor1') ;
		$oFCKeditor->BasePath = '/fckeditor/' ;
		$oFCKeditor->Value = $dulieu['NoiDungHocLT'];
		$oFCKeditor->Create() ;
	?>
   </td></tr></table>
</form>
<?php
}//ket thuc update
if($_GET['action']=='xem' && $_GET['option']=='com_lt'){
			$sql ="SELECT * from `".$shop."`.`lophoclienthong` where MaLopLT = '".$_GET['id']."'";
		$ketqua = mysql_query($sql);
		$dulieu = mysql_fetch_array($ketqua)	
?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="?option=com_lt&action=view"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Back</span></a>
	</div>
	</div>

</div>

<div class="header" style="background: url(images/dashboard/icon-48-article-add.png) no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Tin tức &amp; sự kiện: <small><small>[ Chi tiết]</small></small></h2>
</div><br /><br />
 <table class="contentpaneopen" style="margin-left:10px; padding-left:10px; width:65%" border="0" cellpadding="0" cellspacing="0">
			<tbody><tr>
								<td class="contentheading" style=" font-variant:small-caps" >				
				<?php echo $dulieu['TenLopLT'] ?>		
								</td>
							</tr>
                            <tr>
								<td class="contentheading" >&nbsp;						
								</td>
							</tr>
			</tbody></table>
			
		<table class="contentpaneopen" style="margin-left:10px;padding-left:10px; width:65%"  border="0" cellpadding="0" cellspacing="0">
				<tbody><tr>
			<td colspan="2" valign="top">
               <?php echo $dulieu['NoiDungHocLT'] ?>
			</td>
		</tr>
				</tbody></table>
		<table style="margin-top: 25px;margin-left:10px;padding-left:10px;" width="65%" align="left" bgcolor="#e7e7e7">
		<tbody><tr>
		<th>&nbsp;</th>
		</tr>
		</tbody></table>
<?php	

}
?>

</div>
